package com.zlm.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum JobHuntingStatusEnum {
	 	JOB_STATUS_0(0,"离职，正在找工作"),
	 	JOB_STATUS_1(1,"在职，看看新机会"),
	 	JOB_STATUS_2(2,"在职，急寻新工作"),
	 	JOB_STATUS_3(3,"在职，暂无跳槽打算");

	    private Integer code; 
	    private String name; 
	      
	    private JobHuntingStatusEnum(Integer code, String name){
	        this .code=code;  
	        this .name=name;  
	    }  
	    
	    @SuppressWarnings({ "rawtypes", "unchecked" })
		public static List getJobStatusEnum(){
	    	List list = new ArrayList();
	    	Map<String,Object> map;
	    	for(JobHuntingStatusEnum job:JobHuntingStatusEnum.values()){
	    		map= new HashMap<String, Object>();
	    		map.put("code", job.getCode());
	    		map.put("name", job.getName());
	    		list.add(map);
	    	}
	    	return list;
	    } 
	    
	    public static String getNameByCode(Integer code){
	    	for(JobHuntingStatusEnum job:JobHuntingStatusEnum.values()){
	    		if(job.getCode().equals(code)){
	    			return job.getName();
	    		}
	    	}
	    	return null;
	    } 
	    
	    public static String getJobStatusEnumJsonString(){
	    	StringBuilder builder = new StringBuilder("{");
	    	for(JobHuntingStatusEnum job:JobHuntingStatusEnum.values()){
	    		builder.append("\""+job.getCode()+"\":\""+ job.getName()+"\",");
	    	}
	    	String json=builder.substring(0, builder.length()-1)+"}";
	    	return json;
	    } 
	    
	    @Override
        public  String toString(){
	       return "[code=" + code + ", name=" + name + "]";
	    }  
	    

		public Integer getCode() {
			return code;
		}

		public void setCode(Integer code) {
			this.code = code;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}
}
